﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.XPath;
using System.IO;

namespace LiteXPath
{
    class XPathCompute
    {
        public static string computeXPath(string pXml, string pXPathExpression)
        {
            FileStream fs = new FileStream("temp.xml", System.IO.FileMode.Create);
            fs.Write(pXml,0, (pXml.Length * sizeof(string)) );
            fs.Close();

            XPathDocument xPathDoc = new XPathDocument("temp.xml"); //XPathDocument("CS.xml");
            XPathNavigator xPathNav = xPathDoc.CreateNavigator();

            XPathNodeIterator XPNode = xPathNav.Select(xPathNav.Compile(pXPathExpression));

            return XPNode.ToString();
        }

    }
}
